package com.leet.twopoint;

public class ValidPalindrome {
    public boolean validPalindrome(String s) {
        int j = s.length()-1;
        int i = 0;
        while(i < j){
            if(s.charAt(i) == s.charAt(j)){
                i++;
                j--;
            }else{
                return validPalindrome(s,i+1,j)||validPalindrome(s,i,j-1);
            }
        }
        return false;
    }
    public boolean validPalindrome(String s,int low, int high) {
        for(int i = low, j = high; i < j; i++,j--){
            char c1 = s.charAt(i), c2 = s.charAt(j);
            if(c1 != c2){
                return false;
            }
        }
        return true;
    }
}
